package com.xhs.hawaii.configuration;

import com.xhs.hawaii.framework.thrift.ThriftClientProxy;
import com.xhs.hawaii.framework.zk.ZookeeperHelper;
import com.xhs.hawaii.thrift.scms.ScmsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author tangchuang
 * @version 1.0
 * @since 2018/1/20
 */
@Configuration
public class RpcConfiguration {

    @Autowired
    private ZookeeperHelper zookeeperHelper;

    @Value("${thrift.root.path}")
    private String thriftRootPath;

    @Bean
    public ScmsService.Iface createScmsService() throws Exception {
        ThriftClientProxy<ScmsService.Iface> thriftClientProxy = new ThriftClientProxy(zookeeperHelper, thriftRootPath, ScmsService.class);
        return thriftClientProxy.getObject();
    }
}
